using System.Linq;
using Game.Trade;
using Game.UI;
using UnityEngine;
using UnityEngine.UI;

public class ShopWindow : UIWindow {
    [SerializeField] private TradeListComponent mSellerListComp;

    public Button BtnClose;

    protected override void onInit() {
        BtnClose?.onClick.AddListener(() => {
            UIMgr.Ins.CloseWindow(this);
        });
    }

    protected override void onOpen(object[] args) {
        IBuyer buyer = (IBuyer)args[0];
        ISeller seller = (ISeller)args[1];
        mSellerListComp.OnItemCLick = (data) => {
            TradeSystem.ExecuteTrade(buyer,seller,data);
            mSellerListComp.RefreshData(seller.SellList.ToList());
        };
        mSellerListComp.RefreshData(seller.SellList.ToList());
    }
}
